 {include file="public/header" type="pear-container"/}
		<div class="layui-card">
			<div class="layui-card-body">
				<form class="layui-form layui-form-pane">
					<div class="layui-form-item">
						<div class="layui-inline">
							<button type="submit" class="layui-btn pear-btn-primary" lay-submit lay-filter="save">
								启用选中模板</button>
							<button type="submit" class="layui-btn layui-bg-red" lay-submit lay-filter="delete">
								删除选中模板</button>
						</div>
					</div>
				</form>
				<div id="demoTheme"></div>
			</div>
		</div>
{include file="public/footer"/}
		<script>
			layui.use(['table', 'layer', 'form', 'jquery', 'card','upload'], function() {

				let table = layui.table;
				let form = layui.form;
				let $ = layui.jquery;
				let layer = layui.layer;
				let card = layui.card;
				var upload = layui.upload;
                let MODULE_PATH = "{$Request.root}/ypay.demo_theme/";
				card.render({
					elem: '#demoTheme',
					url: MODULE_PATH + 'index', // 接口数据
					data: [], // 静态数据 
					page: false, // 是否分页
					limit: 8, // 每页数量
					linenum: 4, // 每行数量
					clickItem: function(data){ // 单击事件
						
					}
				})
	           
	            //保存模板
				form.on('submit(save)', function() {
					var data = card.getChecked("demoTheme");
					if(data == null || data == ''){
					    layer.msg('请先选择主题', {
								icon: 2,
								time: 1000
							});
						return false;
					}
					$.post(MODULE_PATH +'saveTheme', data, function (res) {
                        if (res.code === 200) {
                            layer.msg(res.msg, {
								icon: 1,
								time: 1000
							});
							setTimeout(function () {
                            location.reload();
                        }, 2000);
                        } else {
                            layer.msg(res.msg, {
								icon: 2,
								time: 1000
							});
                        }
                    }, 'json');
					return false;
				});
				
				//删除模板
				form.on('submit(delete)', function() {
					var data = card.getChecked("demoTheme");
					if(data == null || data == ''){
					    layer.msg('请先选择主题', {
								icon: 2,
								time: 1000
							});
						return false;
					}
					$.post(MODULE_PATH +'deleteTheme', data, function (res) {
                        if (res.code === 200) {
                            layer.msg(res.msg, {
								icon: 1,
								time: 1000
							});
							setTimeout(function () {
                            location.reload();
                        }, 2000);
                        } else {
                            layer.msg(res.msg, {
								icon: 2,
								time: 1000
							});
                        }
                    }, 'json');
					return false;
				});
				
			
			})
		</script>
	</body>
</html>
